<?php

require 'lib/model/om/BaseConsumPeer.php';

class ConsumPeer extends BaseConsumPeer
{
    // daca un apartament este debransat, consumul se va marca prin acest semn
    const DEBRANSAT = '-';

    /**
     * Returneaza denumirile consumurilor si id-urile criteriilor asociate
     *
     * @see CriteriuPeer::getDescriereConsumuri
     * @return array
     */
    public static function getSummary()
    {
        return CriteriuPeer::getDescriereConsumuri();
    }

    public static function validate(&$value)
    {
        // $stringValidator = new sfValidatorRegex(array('pattern' => '/'.self::DEBRANSAT.'/'));
        $value = trim($value);
        if ($value == self::DEBRANSAT)
        {
            $value = null;
            return true;
        }

        $valueValidator = new ValoareValidator();

        return $valueValidator->validate($value);
    }

    public static function formatValoare($value)
    {
        return is_null($value) ?
            self::DEBRANSAT :
            floatval($value);
    }

}
